import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:paly_android/base/base_widget.dart';

class SysPage extends BaseWidget {
  @override
  BaseWidgetState<BaseWidget> getState() => _SysPageState();
}

class _SysPageState extends BaseWidgetState<SysPage>
    with TickerProviderStateMixin {
  var itemValue;

  late AnimationController animationController;

  @override
  void initState() {
    super.initState();
    animationController = AnimationController(
        lowerBound: 100,
        upperBound: 400,
        vsync: this,
        duration: Duration(milliseconds: 3000));

    animationController.addListener(() {
      setState(() {});
      //当动画执行完成时，动画重复（并反向）
      if (animationController.isCompleted) {
        animationController.repeat(reverse: true);
      }
    });

    // 开始播放动画
    animationController.forward();
  }

  @override
  void dispose() {
    super.dispose();
    // 动画使用完成后必需要销毁
    animationController.dispose();
  }

  @override
  Widget baseBuild(BuildContext context) {
    return Column(
      children: [
        DropdownButton(
          items: [
            DropdownMenuItem(
              child: Text("1"),
              value: "1",
            ),
            DropdownMenuItem(child: Text("2"), value: "2"),
            DropdownMenuItem(child: Text("3"), value: "3"),
            DropdownMenuItem(child: Text("4"), value: "4")
          ],
          alignment: Alignment.center,
          hint: Text("请选择"),
          icon: Icon(
            Icons.airplay,
            size: 20,
          ),
          value: itemValue,
          onChanged: (value) {
            setState(() {
              itemValue = value;
            });
          },
        ),
        Container(
          width: animationController.value,
          color: Colors.lightBlue,
          height: animationController.value,
        )
      ],
    );
  }

  @override
  String getAppBarTitle() => "体系";
}
